package keter.framework.util;

import java.io.File;
import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.io.Files;

public class FileUtil {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);

	
	
	public static LoadingCache<String, byte[]> fileCache = CacheBuilder.newBuilder()
			.maximumSize(1000)
			.build(new CacheLoader<String, byte[]>() {
				public byte[] load(String fileUri) throws IOException {
					// 这里是key根据实际去取值的方法
					return Files.asByteSource(new File(fileUri)).read();
			}
	});
	
	public static LoadingCache<String, String> sizeCache = CacheBuilder.newBuilder()
			.maximumSize(1000)
			.build(new CacheLoader<String, String>() {
				public String load(String fileUri) throws IOException {
					// 这里是key根据实际去取值的方法
					return "0";
			}
	});
}